package com.lc.code.controller;

import com.lc.code.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private CodeService codeService;

    @GetMapping("/create/{email}")
    public boolean genCode(@PathVariable("email") String email){
         return codeService.genCode(email);
    }

    @GetMapping("/validate/{email}/{code}")
    public int validateCode(@PathVariable("email") String email,@PathVariable("code") String code){
         return codeService.validateCode(email,code);
    }
}
